#pragma once

#include <memory>
#include <lib3d/node/Node.h>
#include <lib3d/hard/Manager.h>
#include <lib3d/material/Shader.h>
#include "HardwareDependentObject.h"

namespace liba {
namespace lib3d {
namespace node {

class PlaneImpl;

/** XY Plane 
*
*	XY rectangle is (0, 0, 1, 1)
*/
class Plane
	: public liba::lib3d::node::Node
	, private HardwareDependentObject<hard::Manager, hard::VertexBuffer>
{
	NODE_DEFINITION(Plane)
public:
	static const Atom node_name;

	Plane(const Atom & name, Node * parent);
	~Plane();

	virtual void render_to_list(liba::lib3d::hard::Hardware* hardware, liba::lib3d::hard::RenderList* render_list);
	material::Shader& Shader() { return this->shader; }
public: // ObjectAnsi
	virtual bool on_node( xml::Provider * prov, const std::string & name );
private: // HardwareDependentObject
	virtual void on_add_hardware(hard::Manager::hardware_type* ha);
private:
	void fillVb(hard::VertexBuffer* vb);

	bool vbCreated;
	material::Shader shader;
};

} // namespace node
} // namespace lib3d
} // namespace liba